package com.grape.config;

import com.grape.interceptor.ThreadLocalInterceptor;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 类描述： WebMvcConfig类
 *
 * @author  putao
 * @email   2628279194@qq.com
 */
@Configuration
@AllArgsConstructor
public class WebMvcConfig implements WebMvcConfigurer {

    private final ThreadLocalInterceptor threadLocalInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(threadLocalInterceptor)
                // 拦截判断登录路径
                .addPathPatterns("/**")
                // 放行路径 (开放接口，接口文档)"/opens/**",
                .excludePathPatterns("/opens/**", "/v2/api-docs/**", "/index.html", "/js/**", "/css/**", "/logout", "/swagger-resource/**",
                        "/swagger-resources/**", "/webjars/**", "/doc.html", "/error/**", "/img/**", "/imServer/**");
    }

}
